/**
 * 发布页面的路由控制
 */
class PublishRouter {

  constructor () {
    // 发布页面的路由配置
    this.config = {
      url: '',
      back: false
    }
  }

  /**
   * 更新路由配置
   */
  update (value) {
    if (value === '/pages/home/home' || value === '/pages/person/person' ) {
      this.config.url = value
      this.config.back = false
    } else if (value === '/pages/publish/publish') {
      if (this.config.back) {
        const url = this.config.url || '/pages/home/home'
        wx.switchTab({ url })
        this.config = {
          url: '',
          back: false
        }
      } else {
        wx.navigateTo({ url: '/pages/editor/editor' })
        this.config.back = true
      }
    }
  }

}

export default PublishRouter